<%--
  Created by IntelliJ IDEA.
  User: MWL
  Date: 2019-12-05
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <a href="search">推荐搭配</a>
<table border="1" width="666">
    <tr>
        <td>编号</td>
        <td>型号</td>
        <td>颜色</td>
        <td>风格</td>
        <td>适用人群</td>
        <td>性别</td>
        <td>年龄段</td>
        <td>类型</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${pagedDate.list}" var="p">
        <tr>
            <td>${p.id}</td>
            <td>${p.model}</td>
            <td>${p.color}</td>
            <td>
                <c:forEach items="${all}" var="a">
                    <c:if test="${a.id==p.styleid}">
                        ${a.apply}
                    </c:if>
                </c:forEach>
            </td>
            <td>${p.intended}</td>
            <td>
                <c:if test="${p.gender==1}">
                    女性
                </c:if>
                <c:if test="${p.gender==0}">
                    男性
                </c:if>
            </td>
            <td>
                <c:if test="${p.age>=10&&p.age<=20}">
                    10~20
                </c:if>
            </td>
            <td>
                <c:forEach items="${type}" var="t">
                    <c:if test="${t.id==p.typeid}">
                        ${t.typename}
                    </c:if>
                </c:forEach>
            </td>
            <td><input type="button" value="保存搭配" class="btn" uid="${p.id}"></td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
<script src="statics/jquery.js"></script>
<script>
    $(function(){
        $(".btn").click(function () {
            var id=$(this).attr("uid");
            $.ajax({
                url:"info",
                type:"GET",
                data:{id:id},
                dataType:"json",
                success:function (data) {
                    alert(data);
                },error:function () {
                    alert("创建搭配信息失败");
                }
            })
        })
    })
</script>
